<?php
class Bizprofile_Widgets_Latest_Widget extends Tomato_Widget
{
    protected function _prepareShow()
    {
        $request = Zend_Controller_Front::getInstance()->getRequest();
        $lang = $request->getParam('lang');
        $this->_view->assign('lang', $lang);

        /**
        * Get connection to database
        **/
        $conn = Tomato_Db_Connection::factory()->getMasterConnection();

        /**
        * Enterprise model access to data
        **/
        $enterpriseDao = Tomato_Model_Dao_Factory::getInstance()->setModule('enterprise')->getEnterpriseDao();
        $enterpriseDao->setDbConnection($conn);

        /**
         * Info models of enterprise access to data
        **/
        $infoDao = Tomato_Model_Dao_Factory::getInstance()->setModule('enterprise')->getInfoDao();
        $infoDao->setDbConnection($conn);
        $infoDao->setLang($lang);

        $perPage = 10;
        $offset     = 0;
        $exp = array(
            'deleted' => 0,
			'frontend_active'=>1
        );

        $enterprises = $enterpriseDao->find($offset, $perPage, $exp);
        $this->_view->assign('enterprises', $enterprises);
    }
    protected function _prepareConfig()
    {

    }
}
